package com.yoo.ons.adapter

import androidx.core.view.isVisible
import com.yoo.ons.base.adpater.BaseRecyclerAdapter
import com.yoo.ons.databinding.ItemPremiumCycleBinding
import com.yoo.ons.model.PremiumCycleModel

class PremiumCycleAdapter(val listener:OnListener):BaseRecyclerAdapter<PremiumCycleModel,ItemPremiumCycleBinding>(ItemPremiumCycleBinding::inflate) {
    override fun onBindView(
        holder: VH<ItemPremiumCycleBinding>,
        position: Int,
        item: PremiumCycleModel?
    ) {
        item?.apply {
            holder.binding.cycleContainer.setBackgroundResource(if (item.check) com.yoo.module_res.R.drawable.shape_gradient_d773e5_c62edc_radius_15 else com.yoo.module_res.R.drawable.shape_solid_882c8c_radius_15)
            holder.binding.itemTips.isVisible = item.tip != null
            holder.binding.itemTips.text = item.tip
            holder.binding.itemNum.text = "${item.benefitNum}"
            holder.binding.itemCycle.text = "${item.benefitUnit}"
            holder.binding.itemAmount.text = "${item.price}"
            holder.binding.cycleContainer.setOnClickListener {
                listener.onListener(item)
            }
        }
    }

    interface OnListener{
        fun onListener(item:PremiumCycleModel)
    }
}